const mongoose = require('mongoose');
require('mongoose-long')(mongoose);
let schemaTypes = mongoose.Schema.Types;

//变电站schema
let subSchema = new mongoose.Schema({
    _id: {
        type: mongoose.Schema.ObjectId,
    },
    //变电站id
    sid: {
        type: schemaTypes.Long,
        require: true // 不可为空约束
    },
    //变电站简称
    short: {
        type: String,
        require: true
    },
    //变电站全称
    full: {
        type: String
    },
    //省
    prov: {
        type: schemaTypes.Long,
        require: true
    },
    //市
    city: {
        type: String,
        require: true
    },
    //区
    dist: {
        type: String,
        require: true
    },
    //详细地址
    adress: {
        type: String
    },
    //联系人
    responsor: {
        type: String
    },
    //联系人电话
    phone: {
        type: String
    },
    //联系人邮箱
    mail: {
        type: String
    },
    //创建变电站时间
    crtime: {
        type: schemaTypes.Long
    },
    //编辑变电站时间
    chtime: {
        type: schemaTypes.Long,
    },
    //管理员姓名
    oper: {
        type: String,
    },
    //管理员id
    oper_id: {
        type: String,
    },
    //电压等级
    voltage: {
        type: Number
    },
    //产权单位
    owner: {
        type: String
    },
    //运维单位
    maintainer: {
        type: String
    },
    //调度等级
    grade: {
        type: Number
    },
    //经度
    longitude: {
        type: schemaTypes.Long
    },
    //纬度
    latitude: {
        type: schemaTypes.Long
    },
    //站点状态
    status: {
        type: Number,
    },
    //站点类型
    type: {
        type: String
    },
    //监控厂商
    monitor_factory: {
        type: String
    }
}, {
    versionKey: false
});

//变电站模型
let SubsModel = mongoose.model('SubsModel', subSchema, 'stationcoll');
module.exports = SubsModel;